<?php

use Illuminate\Database\Capsule\Manager as DB;

class Order_ExpressController extends CommonController
{
    public function indexAction()
    {
        $user = \app\service\auth::getUser();
        $order_id = $this->get('order_id', 0);

        $list = orderexpressModel::where('member_id', $user->id)
            ->where('order_id', $order_id)
            ->get();

        json(['code' => 1, 'msg' => '包裹列表', 'data' => $list]);
    }

    public function detailAction()
    {
        $user = \app\service\auth::getUser();
        $id = $this->get('id', 0);
        $order_id = $this->get('order_id', 0);

        $detail = orderexpressModel::with(['log'])
            ->where('member_id', $user->id)
            ->where('order_id', $order_id)
            ->find($id);
        $data = $detail->toArray();
        if (!empty($detail->log)) {
            $log = $detail->log->toArray();
            $data['log'] = array_reverse($log);
        }

        json(['code' => 1, 'msg' => '包裹详情', 'data' => $data]);
    }
}
